﻿@model shop.SanPham

@{
    ViewBag.Title = "Thêm sản phẩm";
}

<div id="content">
    <div id="content-header">
        <div id="breadcrumb">
            <a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> Home</a>
            <a href="#" class="tip-bottom">Form elements</a>
            <a href="#" class="current">Common elements</a>
        </div>
        @*<h1>Common Form Elements</h1>*@
    </div>
    <div class="container-fluid">
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title">
                        <span class="icon">
                            <i class="icon-align-justify"></i>
                        </span>
                        <h5>Thêm sản phẩm</h5>
                    </div>
                    <div class="widget-content nopadding">
                        @using (Html.BeginForm("create", "sanpham", FormMethod.Post, new { enctype = "multipart/form-data",@id="formsanpham", @class = "form-horizontal" }))
                        {
                            @Html.AntiForgeryToken()
                            @Html.ValidationSummary(true)
                            <div class="control-group">
                                <label class="control-label">Tên sản phẩm :</label>
                                <div class="controls">
                                    <input type="text" class="required span3" name="TenSP"  placeholder="Nhập tên sản phẩm" />                                     
                                  </div>
                            </div>                          
                            <div class="control-group">
                                <label class="control-label">Mã sản phẩm:</label>
                                <div class="controls">
                                    <input id="MaSP" name="MaSP" type="text" class="required" class="span3" placeholder="Nhận mã sản phẩm" /><div id="errormasp"></div>
                                    @*<span class="help-block">Description field</span>*@
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">Giá Tiền:</label>
                                <div class="controls">
                                    <input type="text" name="Gia" class="required number" class="span3" placeholder="Nhận mã sản phẩm" />
                                    @*<span class="help-block">Description field</span>*@
                                   
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">Nội dung sản phẩm</label>
                                <div class="controls">
                                    <textarea name="NoiDung" class="required" id="NoiDungSanPhan" class="span20" placeholder="textarea (span20)"></textarea>
                                </div>
                            </div>

                            <div class="control-group">
                                <label class="control-label">Danh mục</label>
                                <div class="controls ">
                                    <!-- danh muc-->
                                    @Html.Action("DropMenuChaDM","Partial",new {type="DM"})
                                </div>
                            </div>
                                  
                            <div class="control-group">
                                <label class="control-label">Thương Hiệu</label>
                                <div class="controls ">
                                    @Html.Action("DropMenuChaTH", "Partial", new { type = "TH" })
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">Nghề nghiệp</label>
                                <div class="controls ">
                                    @Html.Action("DropMenuNN","Partial")
                                </div>
                            </div>

                            @*<div class="control-group">
                                <label class="control-label">Mã Màu</label>
                                <div class="controls">
                                   
                                    @Html.Action("BangMau","Partial")
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label">Size</label>
                                <div class="controls">
                                    
                                   @Html.Action("Size","Partial")
                                </div>

                            </div>*@
                            <div class="control-group">
                                <label class="control-label">Hình ảnh đại diện</label>
                                <div class="controls">
                                    <input type="file" name="AnhSP" accept="jpg|gif|png|jpeg" />
                                </div>
                            </div>
                            <div class="form-actions">
                                <button id="them" type="submit" class="btn btn-success">Thêm</button>
                            </div>
                        }
                       
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="row-fluid">
    <div id="footer" class="span12"> 2012 &copy; Marutii Admin. Brought to you by <a href="http://themedesigner.in">Themedesigner.in</a> </div>
</div>
<script src="~/Content/themes/maruti/js/jquery.min.js"></script>
<script src="~/Content/themes/maruti/js/jquery.ui.custom.js"></script>
<script src="~/Content/themes/maruti/js/bootstrap.min.js"></script>
<script src="~/Content/themes/maruti/js/bootstrap-colorpicker.js"></script>
<script src="~/Content/themes/maruti/js/bootstrap-datepicker.js"></script>
<script src="~/Content/themes/maruti/js/jquery.uniform.js"></script>
<script src="~/Content/themes/maruti/js/select2.min.js"></script>
<script src="~/Content/themes/maruti/js/maruti.js"></script>
<script src="~/Content/themes/maruti/js/maruti.form_common.js"></script>
<script src="~/Plugin/ckeditor/ckeditor.js"></script>
<script src="~/Content/js/jquery.validate.js"></script>
<script src="~/Content/js/localization/messages_vi.js"></script>
<script type="text/javascript">
    CKEDITOR.replace("NoiDungSanPhan", {
        toolbar: [
            { name: 'document', items: ['-', 'NewPage', 'Preview', '-', 'Templates'] },	// Defines toolbar group with name (used to create voice label) and items in 3 subgroups.
            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'],			// Defines toolbar group without name.
            '/',																					// Line break - next group will be placed in new line.
            { name: 'basicstyles', items: ['Bold', 'Italic'] }
        ]
    });

    $(document).ready(function () {
        $('#formsanpham').validate({
            errorClass: "help-inline",
            errorElement: "span",
        });

        $('#MaSP').blur(function () {
            var url = "/admin/sanpham/checkmasp";
            var name = $('#MaSP').val();
            if (name != "")
            {
                $.get(url, { input: name }, function (data) {
                    if(data=="1")
                    {
                        $('#errormasp').html("<span style='color:red;'>Mã sản Phẩm đã sử dụng.</span>");
                        $('#MaSP').css("border:solid 1px red;");
                        $("#them").attr("disabled", "disabled");
                    }
                    if(data=="0")
                    {
                        $('#errormasp').html("<span style='color:green;'>có thẻ sử dụng</span>");
                        $("#them").removeAttr("disabled");
                    }
                });
            }

        });

    });
</script>

